﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace GameJamKingdom
{

    class CreditsState : State
    {
        SpriteFont font;
        Texture2D creditsImage;
        KeyboardState cKeyState;
        int timeElapsed;

        public CreditsState(Game1 cGame)
        {
            Initialize(cGame);
        }

        public override void Initialize(Game1 cGame)
        {
            font = cGame.Content.Load<SpriteFont>("ScoreFont");
            creditsImage = cGame.Content.Load<Texture2D>("CREDITSscreen");
            timeElapsed = 0;
        }

        public override void Update(Game1 cGame, GameTime gameTime)
        {
            
            cKeyState = Keyboard.GetState();
            timeElapsed += (int)gameTime.ElapsedGameTime.TotalMilliseconds;

            if ((cKeyState.IsKeyDown(Keys.Enter) || (cKeyState.IsKeyDown(Keys.Left)) || (cKeyState.IsKeyDown(Keys.Escape))) && (timeElapsed > 100))
            {
                timeElapsed = 0;
                cGame.cState = "menu";
            }
        }

        public override void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Begin();
            spriteBatch.Draw(creditsImage, new Vector2(0, 0), Color.White);
            spriteBatch.End();
        }
    }
}
